import Cookies from 'js-cookie'

/**
 * 令牌 key
 */
const tokenKey = 'web-token'

/**
 * 获取令牌 key
 * @return 令牌 key
 */
export const getTokenKey = () => tokenKey

/**
 * 获取令牌
 * @return 令牌
 */
export const getToken = () => Cookies.get(tokenKey) || ''

/**
 * 设置令牌
 * @param token 令牌
 */
export const setToken = (token: string) => Cookies.set(tokenKey, token)

/**
 * 删除令牌
 */
export const removeToken = () => Cookies.remove(tokenKey)

/**
 * App 左侧菜单显示状态 key
 */
const appSidebarStatusKey = 'App-Sidebar-Status'

/**
 * 获取 App 左侧菜单显示状态 key
 * @return App 左侧菜单显示状态 key
 */
export const getAppSidebarStatusKey = () => appSidebarStatusKey

/**
 * 获取 App 左侧菜单显示状态
 * @return  App 左侧菜单显示状态
 */
export const getAppSidebarStatus = () => Cookies.get(appSidebarStatusKey) || 'opend'

/**
 * 设置 App 左侧菜单显示状态
 * @param token  App 左侧菜单显示状态
 */
export const setAppSidebarStatus = (appSidebarStatus: string) => Cookies.set(appSidebarStatusKey, appSidebarStatus)

/**
 * App 语言 key
 */
const appLanguageKey = 'App-Language-Status'

/**
 * 获取 App 语言 key
 * @return App 语言 key
 */
export const getAppLanguageKey = () => appLanguageKey

/**
 * 获取 App 语言
 * @return  App 语言
 */
export const getAppLanguage = () => Cookies.get(appLanguageKey) || 'zh'

/**
 * 设置 App 语言
 * @param token  App 语言
 */
export const setAppLanguage = (appLanguage : string) => Cookies.set(appLanguageKey, appLanguage)

/**
 * App 页面元素尺寸 key
 */
const appComponentSizeKey = 'App-Component-Size'

/**
 * 获取 App 页面元素尺寸 key
 * @return App 页面元素尺寸 key
 */
export const getAppComponentSizeKey = () => appComponentSizeKey

/**
 * 获取 App 页面元素尺寸
 * @return  App 页面元素尺寸
 */
export const getAppComponentSize = () => Cookies.get(appComponentSizeKey) || 'medium'

/**
 * 设置 App 页面元素尺寸
 * @param token  App 页面元素尺寸
 */
export const setAppComponentSize = (appComponentSize : string) => Cookies.set(appComponentSizeKey, appComponentSize)
